package leetcode_day._2021._202107._0110;

import java.util.Arrays;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/7/2 18:39
 * 雪糕的最大数量
 * 算法：贪心
 */
public class _02_1833 {

    public int maxIceCream(int[] costs, int coins) {
        Arrays.sort(costs);
        int ans = 0;
        for (int cost : costs) {
            if (coins - cost >= 0) ++ans;
            coins -= cost;
        }
        return ans;
    }

}
